#!/usr/bin/env node
var geojsonMerge = require('./'),
    stream = geojsonMerge.mergeFeatureCollectionStream,
    merge = geojsonMerge.merge,
    fs = require('fs'),
    argv = require('minimist')(process.argv.slice(2));

if (!argv._.length || argv.help) {
  console.log('usage: geojson-merge [-s] FILE FILE2 FILE3');
  console.log('\n  --stream (or -s): use streaming mode for large files');
  return;
}

if (argv.s || argv.stream) {
  stream(argv._).pipe(process.stdout)
} else {
  process.stdout.write(JSON.stringify(merge(argv._.map(function(n) {
      return JSON.parse(fs.readFileSync(n));
  })), null, 2));
}
